<?php namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use tinymeng\tools\FileTool;

class CommonCommand extends Command {

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'CommonCommand';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'CommonCommand';

    public $limit = 1000;//分页条数

    public $appid = '1717047006';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        // 数据表前缀
        defined('DB_PREFIX') or define('DB_PREFIX', DB::connection()->getTablePrefix());
        // 数据库名
        defined('DB_NAME') or define('DB_NAME', DB::connection()->getDatabaseName());
        $this->day = date("Ymd",NOW_TIME);//今天日期
        parent::__construct();
    }

    /**
     * 记录日志文件
     * @param $message
     */
    public function writeln($message,$file_name="",$echo=true){
        if(empty($file_name)) $file_name = "command_".str_replace(":","_",$this->getName());
        FileTool::writeLog($this->getName().' '.$message,$file_name, $echo);
    }

}
